package com.lanca.filter;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {

    /**
     * java代码配置路由(不推荐) java代码配置 优先级高于配置文件
     * 推荐yml配置文件方式
     *
     * @param builder builder
     * @return RouteLocator
     */
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("product_route", r -> r.path("/list/**")
                        .uri("http://localhost:8787"))
                .build();
    }
}
